<?php

namespace App\Http\Middleware;

use Illuminate\Http\Request;

class Bouncer
{

    public function handle(Request $request, \Closure $next, $ability)
    {
        $user = $request->user();
        if (!$user->can($ability)) {
            return redirect('admin/authorize');
        }
        $response = $next($request);
        return $response;
    }
}
